package com.dingreading.cloud.admin.service.impl;

import com.dingreading.cloud.admin.entity.table.CmactivationCodeLogTableDef;
import com.dingreading.cloud.common.util.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.dingreading.cloud.admin.entity.CmactivationCodeLog;
import com.dingreading.cloud.admin.mapper.CmactivationCodeLogMapper;
import com.dingreading.cloud.admin.service.CmactivationCodeLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 激活码分发记录表 服务层实现。
 *
 * @author EDY
 * @since 2025-10-29
 */
@Service
public class CmactivationCodeLogServiceImpl extends BaseServiceImpl<CmactivationCodeLogMapper, CmactivationCodeLog, CmactivationCodeLogTableDef> implements CmactivationCodeLogService {

    @Override
    protected CmactivationCodeLogTableDef getTable() {
        return CmactivationCodeLogTableDef.cmactivationCodeLog;
    }

    @Override
    public Page<CmactivationCodeLog> pageList(PageUtil pageUtil, String headStaffUid, String headStaffName, String keyword) {
        QueryCondition condition = QueryCondition.createEmpty();
        if (StringUtils.isNotBlank(keyword))
            condition.and(table.addStaffName.like(keyword).or(table.storeName.like(keyword)));
        QueryWrapper wrapper = QueryWrapper.create()
                .where(condition);
        return getMapper().paginate(Page.of(pageUtil.getPage(), pageUtil.getRows()), wrapper);
    }
}
